﻿<%@ WebHandler Language="C#" Class="gif" %>
using System;
using System.Web;
using System.IO;
using Common;
public class gif : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
    public void ProcessRequest (HttpContext context) {
        
        ValidateCode gif = new ValidateCode();//初始化验证码生成类
        string valid = "";//定义随机数
        MemoryStream ms = gif.Create(out valid);//获取包括验证码图片的内存流
        context.Session["CheckCode"] = valid;//验证码存储在Session中，供验证。
        context.Response.ClearContent();//清空输出流
        context.Response.ContentType = "image/png";//输出流的格式
        context.Response.BinaryWrite(ms.ToArray());//输出
        context.Response.End();
    }
    public bool IsReusable {//不重用
        get {
            return false;
        }
    }

}